//BC157 素数回文
import java.util.;

注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
   public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       char[] arr = in.next().toCharArray();
       int len = arr.length;
       long a = 0L;
       int j = 0;
       for (int i = 0; i  len; i++) {
           a = 10;
           a += arr[i] - '0';
       }
       for (int i = len-2; i = 0; i--) {
           a = 10;
           a += arr[i] - '0';
       }
       System.out.println(fun1(a)  prime  noprime);
   }

   public static boolean fun1(long a) {
       if (a  2) {
           return false;
       }
       for (long i = 2; i = Math.sqrt(a); i++) {
           if (a % i == 0) {
               return false;
           }
       }
       return true;
   }
}
